//********************************************************************
// 
//  file:  LogManagement.cs
// 
//  (C) Copyright 2010, Diomede Corporation
//  All rights reserved
// 
//  Use, modification, and distribution is subject to   
//  the New BSD License (See accompanying file license.txt).
// 
//********************************************************************

using System;
using System.Collections.Generic;
using System.Text;
using data.diomedestorage.com;
using Diomede.SDK.Enums;

namespace Diomede.SDK
{
    #region Interface

    /// <summary>
    /// Interface for Logs management.
    /// </summary>
    public interface ILogsManagement
    {
        /// <summary>
        /// Provides interface for searching merge activity logs.
        /// </summary>
        /// <param name="dateFrom">Search start date.</param>
        /// <param name="dateTo">Search end date.</param>
        /// <param name="offset">Search offset.</param>
        /// <param name="pageSize">Search page Size.</param>
        /// <returns>Will return Search Merge Logs Execution result, see <see cref="ISearchMergeLogsExecResult"/> for more information.</returns>
        ISearchMergeLogsExecResult SearchMergedActivityLogs(DateTime? dateFrom, DateTime? dateTo, long offset, long pageSize);

        /// <summary>
        /// Provides interface for searching upload logs.
        /// </summary>
        /// <param name="fileID">File ID.</param>
        /// <param name="dateFrom">Search start date.</param>
        /// <param name="dateTo">Search end date.</param>
        /// <param name="uploaderIP">IP of the client.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The page size.</param>
        /// <returns>Will return Search Upload Logs Execution result, see <see cref="ISearchUploadLogsExecResult"/> for more information.</returns>
        /// <code></code>
        /// <code lang="VB.NET"></code>
        ISearchUploadLogsExecResult SearchUploadLogs(long? fileID, DateTime? dateFrom, DateTime? dateTo, string uploaderIP, long offset, long pageSize);

        /// <summary>
        /// Provides interface for searching download logs.
        /// </summary>
        /// <param name="file">File ID.</param>
        /// <param name="dateFrom">Search start date.</param>
        /// <param name="dateTo">Search start date.</param>
        /// <param name="downloadToken">Download token.</param>
        /// <param name="downloaderIP">Ip of the client.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The page size.</param>
        /// <returns>Will return Search Download Logs Execution result, see <see cref="ISearchDownloadLogsExecResult"/> for more information.</returns>
        /// <code></code>
        /// <code lang="VB.NET"></code>
        ISearchDownloadLogsExecResult SearchDownloadLogs(int? file, DateTime? dateFrom, DateTime? dateTo, string downloadToken, string downloaderIP, long offset, long pageSize);

        /// <summary>
        /// Search for log in logs.
        /// </summary>
        /// <param name="startDate">Search start date.</param>
        /// <param name="endDate">Search start date.</param>
        /// <param name="loginIP">Ip of the client.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The page size.</param>
        /// <returns>Will return Search Login Logs Execution result, see <see cref="ISearchLoginLogsExecResult"/> for more information.</returns>
        ISearchLoginLogsExecResult SearchLoginLogs(DateTime? startDate, DateTime? endDate, string loginIP, long offset, long pageSize);

        /// <summary>
        /// Searches for invoice logs.
        /// </summary>
        /// <param name="startDate">Start Date.</param>
        /// <param name="endDate">End Date.</param>
        /// <param name="status">Status of the Invoice.</param>
        /// <returns>Will return Invoice Execution Result, see <see cref="ISearchInvoiceLogsExecResult"/>.</returns>
        ISearchInvoiceLogsExecResult SearchInvoiceLogs(DateTime? startDate, DateTime? endDate, InvoiceStatus status);

    }

    /// <summary>
    /// Search login logs execution result interface
    /// </summary>
    public interface ISearchLoginLogsExecResult
    {
        /// <summary>
        /// Result status for the execution of a session methods,
        /// see <see cref="Enums.ExecutionResults"/> for more information.
        /// </summary>
        Enums.ExecutionResults Status { get; set;}
        /// <summary>
        /// Result message for the execution of a session methods
        /// </summary>
        string Message { get; set;}

        /// <summary>
        /// Log in log results.
        /// </summary>
        List<LoginLogEntry> Logs { get; set;}

        /// <summary>
        /// Total results count for this search.
        /// </summary>
        Int64 TotalResultCount { get; set;}
    }


    /// <summary>
    /// Search merge logs execution result interface.
    /// </summary>
    public interface ISearchMergeLogsExecResult : IExecResult
    {
        /// <summary>
        /// File Total Information.
        /// </summary>
        SearchFilesTotalInfo[] FileTotalInfo { get;set;}
    }

    /// <summary>
    /// Search upload logs execution result interface.
    /// </summary>
    public interface ISearchUploadLogsExecResult : IExecResult
    {
        /// <summary>
        /// 
        /// </summary>
        List<UploadLogEntry> Logs { get;set;}

        /// <summary>
        /// 
        /// </summary>
        long TotalResultCount { get;set;}
    }

    /// <summary>
    /// Search download logs execution result interface.
    /// </summary>
    public interface ISearchDownloadLogsExecResult : IExecResult
    {
        /// <summary>
        /// Download log results.
        /// </summary>
        List<DownloadLogEntry> Logs { get;set;}
        /// <summary>
        /// Total result count.
        /// </summary>
        long TotalResultCount { get;set;}
    }

    /// <summary>
    /// Search invoice logs execution result interface.
    /// </summary>
    public interface ISearchInvoiceLogsExecResult : IExecResult
    {
        /// <summary>
        /// Invoice logs results.
        /// </summary>
        List<InvoiceLogEntry> Invoices { get;set; }
    }


    #endregion

    #region implementation
    /// <summary>
    /// ISearchInvoiceLogsExecResult implementation. See <see cref="ISearchInvoiceLogsExecResult"/> for more information. 
    /// </summary>
    public class SearchInvoiceLogsExecResult : ISearchInvoiceLogsExecResult
    {
        /// <summary>
        /// Create new instance of SearchInvoiceLogsExecResult.
        /// </summary>
        public SearchInvoiceLogsExecResult()
        {

        }

        /// <summary>
        /// Create new instance of SearchInvoiceLogsExecResult, with status and message as parameters.
        /// </summary>
        /// <param name="status">Returned status.</param>
        /// <param name="message">Returned message.</param>
        public SearchInvoiceLogsExecResult(ExecutionResults status, string message)
        {
            this.status = status;
            this.message = message;
        }

        /// <summary>
        /// Create new instance of SearchInvoiceLogsExecResult, with status, message and invoices as parameters.
        /// </summary>
        /// <param name="status">Returned status.</param>
        /// <param name="message">Returned message.</param>
        /// <param name="invoices">List of invoices returned.</param>
        public SearchInvoiceLogsExecResult(ExecutionResults status, string message, InvoiceLogEntry[] invoices)
        {
            this.status = status;
            this.message = message;
            this.invoices = new List<InvoiceLogEntry>(invoices);
        }

        /// <summary>
        /// Create new instance of ProductsExecResult, with an Exception as parameter.
        /// </summary>
        /// <param name="ex">Returned exception.</param>
        public SearchInvoiceLogsExecResult(Exception ex)
        {
            status = ExecutionResults.Failed;
            message = ex.Message;
        }

        #region ISearchInvoiceLogsExecResult Members


        private List<InvoiceLogEntry> invoices;
        /// <summary>
        /// List of invoices.
        /// </summary>
        List<InvoiceLogEntry> ISearchInvoiceLogsExecResult.Invoices
        {
            get
            {
                return invoices;
            }
            set
            {
                invoices = value;
            }
        }

        #endregion

        #region IExecResult Members

        ExecutionResults status;
        /// <summary>
        /// IExecResult.Status implementation, see <see cref="IExecResult.Status">IExecResult.Status</see> for more information.
        /// </summary>
        ExecutionResults IExecResult.Status
        {
            get { return status; }
            set { status = value; }
        }

        string message;
        /// <summary>
        /// IExecResult.Message implementation, see <see cref="IExecResult.Message">IExecResult.Message</see> for more information.
        /// </summary>
        string IExecResult.Message
        {
            get { return message; }
            set { message = value; }
        }

        #endregion


    }







    /// <summary>
    /// ISearchLoginLogsExecResult implementation, see <see cref="ISearchLoginLogsExecResult"/> for more information.
    /// </summary>
    public class SearchLoginLogsExecResult : ISearchLoginLogsExecResult
    {
        /// <summary>
        /// Default constructor.
        /// </summary>
        public SearchLoginLogsExecResult()
        {
        }
        /// <summary>
        /// SearchLoginLogsExecResult constructor that will accept status and message as parameters.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        public SearchLoginLogsExecResult(Enums.ExecutionResults status, string message)
        {
            this.status = status;
            this.message = message;
        }

        /// <summary>
        /// SearchSearchLoginLogsExecResult constructor that will accept status, message, the logs and the total results as parameters.
        /// </summary>
        /// <param name="status">Result Status.</param>
        /// <param name="message">Result message.</param>
        /// <param name="logs">Result logs.</param>
        /// <param name="totalResults">Number of results returned.</param>
        public SearchLoginLogsExecResult(Enums.ExecutionResults status, string message, LoginLogEntry[] logs, long totalResults)
        {
            this.status = status;
            this.message = message;
            this.logs = new List<LoginLogEntry>(logs);
            this.totalResultCount = totalResults;
        }

        /// <summary>
        /// SearchLoginLogsExecResult constructor that will accept exception and filter as parameters.
        /// </summary>
        /// <param name="ex">Exception.</param>
        public SearchLoginLogsExecResult(Exception ex)
        {
            status = Diomede.SDK.Enums.ExecutionResults.Failed;
            message = ex.Message;
        }

        #region ISearchLoginLogsExecResult Members


        Enums.ExecutionResults status;
        /// <summary>
        /// ISearchLoginLogsExecResult.Status implementation, see <see cref="ISearchLoginLogsExecResult.Status"/> for more information.
        /// </summary>
        Enums.ExecutionResults ISearchLoginLogsExecResult.Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

        string message;
        /// <summary>
        /// ISearchLoginLogsExecResult.Message implementation, see <see cref="ISearchLoginLogsExecResult.Message"/> for more information.
        /// </summary>
        string ISearchLoginLogsExecResult.Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
            }
        }

        List<LoginLogEntry> logs;
        /// <summary>
        /// ISearchLoginLogsExecResult.Logs implementation, see <see cref="ISearchLoginLogsExecResult.Logs"/> for more information.
        /// </summary>
        List<LoginLogEntry> ISearchLoginLogsExecResult.Logs
        {
            get
            {
                return logs;
            }
            set
            {
                logs = value;
            }
        }

        long totalResultCount;
        /// <summary>
        /// ISearchLoginLogsExecResult.TotalResultCount implementation, see <see cref="ISearchLoginLogsExecResult.TotalResultCount"/> for more information.
        /// </summary>
        long ISearchLoginLogsExecResult.TotalResultCount
        {
            get { return totalResultCount; }
            set { totalResultCount = value; }
        }

        #endregion
    }

    /// <summary>
    /// ISearchMergeLogsExecResult implementation, see <see cref="ISearchMergeLogsExecResult"/> for more information.
    /// </summary>
    public class SearchMergeLogsExecResult : ISearchMergeLogsExecResult
    {
        /// <summary>
        /// Creates the default instance.
        /// </summary>
        public SearchMergeLogsExecResult()
        {
        }

        /// <summary>
        /// Creates instance that accepts status and message.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        public SearchMergeLogsExecResult(ExecutionResults status, string message)
        {
            this.status = status;
            this.message = message;
        }

        /// <summary>
        /// Creates instance that accepts status message and SearchFilesTotalInfo.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        /// <param name="info">Search files total information.</param>
        public SearchMergeLogsExecResult(ExecutionResults status, string message, SearchFilesTotalInfo[] info)
        {
            this.status = status;
            this.message = message;
            this.fileTotalInfo = info;
        }

        /// <summary>
        /// Creates an instance that accepts exception.
        /// </summary>
        /// <param name="ex">Result exception.</param>
        public SearchMergeLogsExecResult(Exception ex)
        {
            this.status = ExecutionResults.Failed;
            this.message = ex.Message;
        }



        #region IExecResult Members

        ExecutionResults status;
        /// <summary>
        /// Execution Result status, see <see cref="IExecResult.Status"/> for more information.
        /// </summary>
        ExecutionResults IExecResult.Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

        string message;
        /// <summary>
        /// Execution Result message, see <see cref="IExecResult.Message"/> for more information.
        /// </summary>
        string IExecResult.Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
            }
        }

        #endregion

        #region ISearchMergeLogsExecResult Members

        SearchFilesTotalInfo[] fileTotalInfo;
        /// <summary>
        /// File total information.
        /// </summary>
        SearchFilesTotalInfo[] ISearchMergeLogsExecResult.FileTotalInfo
        {
            get
            {
                return fileTotalInfo;
            }
            set
            {
                fileTotalInfo = value;
            }
        }

        #endregion
    }

    /// <summary>
    /// SearchUploadLogsExecResult implementation, see <see cref="ISearchUploadLogsExecResult"/>  for more information. 
    /// </summary>
    public class SearchUploadLogsExecResult : ISearchUploadLogsExecResult
    {
        /// <summary>
        /// Object constructor that will accept status, message.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        public SearchUploadLogsExecResult(ExecutionResults status, string message)
        {
            ISearchUploadLogsExecResult t = this;
            t.Status = status;
            t.Message = message;
        }

        /// <summary>
        /// Object constructor that will accept status, message, and StoreFile.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        /// <param name="logs">The logs.</param>
        /// <param name="totalCount">Total result counts.</param>
        public SearchUploadLogsExecResult(ExecutionResults status, string message, UploadLogEntry[] logs, long totalCount)
        {
            ISearchUploadLogsExecResult t = this;
            t.Status = status;
            t.Message = message;
            t.Logs = new List<UploadLogEntry>(logs);
            t.TotalResultCount = totalCount;
        }

        /// <summary>
        /// Object constructor that will accept Exception, will set the Status = Failed, and Message = Exception.Message
        /// </summary>
        /// <param name="ex">Exception.</param>
        public SearchUploadLogsExecResult(Exception ex)
        {
            ISearchUploadLogsExecResult t = this;
            t.Status = ExecutionResults.Failed;
            t.Message = ex.Message;
        }

        #region ISearchUploadLogsExecResult Members


        List<UploadLogEntry> logs;
        /// <summary>
        /// Upload Logs.
        /// </summary>
        List<UploadLogEntry> ISearchUploadLogsExecResult.Logs
        {
            get
            {
                return logs;
            }
            set
            {
                logs = value;
            }
        }

        long totalResultCount;
        /// <summary>
        /// Total result count.
        /// </summary>
        long ISearchUploadLogsExecResult.TotalResultCount
        {
            get
            {
                return totalResultCount;
            }
            set
            {
                totalResultCount = value;
            }
        }

        #endregion

        #region IExecResult Members

        ExecutionResults status;
        /// <summary>
        /// Execution Result status, see <see cref="IExecResult.Status"/> for more information.
        /// </summary>
        ExecutionResults IExecResult.Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

        string message;
        /// <summary>
        /// Execution Result message, see <see cref="IExecResult.Message"/> for more information.
        /// </summary>
        string IExecResult.Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
            }
        }

        #endregion

    }

    /// <summary>
    /// Implementation of the search download log result. See <see cref="ISearchDownloadLogsExecResult"/> for more information.
    /// </summary>
    public class SearchDownloadLogExecResult : ISearchDownloadLogsExecResult
    {
        /// <summary>
        /// Creates default instance of the SearchDownloadLogExecResult.
        /// </summary>
        public SearchDownloadLogExecResult()
        {
        }

        /// <summary>
        /// Creates instance of SearchDownloadLogExecResult that accepts status and message.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        public SearchDownloadLogExecResult(ExecutionResults status, string message)
        {
            this.status = status;
            this.message = message;
        }

        /// <summary>
        /// Creates instance of SearchDownloadLogExecResult that accepts status, message, the logs, and total results.
        /// </summary>
        /// <param name="status">Result status.</param>
        /// <param name="message">Result message.</param>
        /// <param name="logs">Download entry logs.</param>
        /// <param name="totalResults">Total results.</param>
        public SearchDownloadLogExecResult(ExecutionResults status, string message, DownloadLogEntry[] logs, long totalResults)
        {
            this.status = status;
            this.message = message;
            this.logs = new List<DownloadLogEntry>(logs);
            this.totalResultCount = totalResults;
        }

        /// <summary>
        /// Creates instance of SearchDownloadLogExecResult that accepts an exception. Mostly this is failed results.
        /// </summary>
        /// <param name="ex">The exception thrown by the execution.</param>
        public SearchDownloadLogExecResult(Exception ex)
        {
            this.status = ExecutionResults.Failed;
            this.message = ex.Message;
        }

        #region ISearchDownloadLogsExecResult Members

        List<DownloadLogEntry> logs;
        /// <summary>
        /// The list of download logs returned.
        /// </summary>
        List<DownloadLogEntry> ISearchDownloadLogsExecResult.Logs
        {
            get
            {
                return logs;
            }
            set
            {
                logs = value;
            }
        }

        long totalResultCount;
        /// <summary>
        /// The total result count.
        /// </summary>
        long ISearchDownloadLogsExecResult.TotalResultCount
        {
            get
            {
                return totalResultCount;
            }
            set
            {
                totalResultCount = value;
            }
        }

        #endregion

        #region IExecResult Members

        ExecutionResults status;
        /// <summary>
        /// Execution Result status, see <see cref="IExecResult.Status"/> for more information.
        /// </summary>
        ExecutionResults IExecResult.Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

        string message;
        /// <summary>
        /// Execution Result message, see <see cref="IExecResult.Message"/> for more information.
        /// </summary>
        string IExecResult.Message
        {
            get
            {
                return message;
            }
            set
            {
                message = value;
            }
        }

        #endregion
    }

    public partial class Session : ILogsManagement
    {

        #region ILogsManagement Members
        /// <summary>
        /// ILogsManagement.SearchMergedActivityLogs implementation. See <see cref="ILogsManagement.SearchMergedActivityLogs"/> for more information.
        /// </summary>
        /// <param name="dateFrom"></param>
        /// <param name="dateTo"></param>
        /// <returns></returns>
        ISearchMergeLogsExecResult ILogsManagement.SearchMergedActivityLogs(DateTime? dateFrom, DateTime? dateTo, long offset, long pageSize)
        {
            if (service == null || string.IsNullOrEmpty(token))
                return new SearchMergeLogsExecResult(ExecutionResults.Failed, "No active session.");

            try
            {
                long total;
                SearchFilesTotalInfo[] info = service.SearchFilesTotalLog(token, dateFrom, dateTo, offset, pageSize, out total);
                return new SearchMergeLogsExecResult(ExecutionResults.Success, "Execution successful.", info);
            }
            catch (Exception ex)
            {
                return new SearchMergeLogsExecResult(ex);
            }
        }


        /// <summary>
        /// ILogsManagement.SearchUploadLogs implementation. See <see cref="ILogsManagement.SearchUploadLogs"/> for more information.
        /// </summary>
        /// <param name="fileID">File ID.</param>
        /// <param name="dateFrom">Search start date.</param>
        /// <param name="dateTo">Search end date.</param>
        /// <param name="uploaderIP">IP of the uploader.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The page size.</param>
        /// <returns>Will return Search Upload Logs Execution result, see <see cref="ISearchUploadLogsExecResult"/> for more information.</returns>
        ISearchUploadLogsExecResult ILogsManagement.SearchUploadLogs(long? fileID, DateTime? dateFrom, DateTime? dateTo, string uploaderIP, long offset, long pageSize)
        {
            if (service == null || string.IsNullOrEmpty(token))
                return new SearchUploadLogsExecResult(ExecutionResults.Failed, "No active session.");

            try
            {
                long total;
                UploadLogEntry[] entries = service.SearchUploadLog(token, fileID, dateFrom, dateTo, uploaderIP, offset, pageSize, out total);
                
                return new SearchUploadLogsExecResult(ExecutionResults.Success, "Execution successful.", entries, total);
            }
            catch (Exception ex)
            {
                return new SearchUploadLogsExecResult(ex);
            }
        }

        /// <summary>
        /// ILogsManagement.SearchDownloadLogs implementation. See <see cref="ILogsManagement.SearchDownloadLogs"/> for more information.
        /// </summary>
        /// <param name="fileID">File ID.</param>
        /// <param name="dateFrom">Search start date.</param>
        /// <param name="dateTo">Search end date.</param>
        /// <param name="downloadToken">Download token.</param>
        /// <param name="downloaderIP">Ip of the downloader.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The page size.</param>
        /// <returns>Will return Search Download Logs Execution result, see <see cref="ISearchDownloadLogsExecResult"/> for more information.</returns>
        ISearchDownloadLogsExecResult ILogsManagement.SearchDownloadLogs(int? fileID, DateTime? dateFrom, DateTime? dateTo, string downloadToken, string downloaderIP, long offset, long pageSize)
        {
            if (service == null || string.IsNullOrEmpty(token))
                return new SearchDownloadLogExecResult(ExecutionResults.Failed, "No active session.");

            try
            {
                long total;
                DownloadLogEntry[] entries = service.SearchDownloadLog(token, fileID, dateFrom, dateTo, downloadToken, downloaderIP, 0, 100, out total);
                return new SearchDownloadLogExecResult(ExecutionResults.Success, "Execution successful.", entries, total);
            }
            catch (Exception ex)
            {
                return new SearchDownloadLogExecResult(ex);
            }
        }

        #endregion

        #region ILogsManagement Members

        /// <summary>
        /// ILogsManagement.SearhLoginLogs implementation, see <see cref="ILogsManagement.SearchLoginLogs(DateTime? , DateTime? , string , long , long )"/> for more information.
        /// </summary>
        /// <param name="startDate">Starting date of search.</param>
        /// <param name="endDate">End date of search.</param>
        /// <param name="loginIP">IP of the logged in client.</param>
        /// <param name="offset">The offset.</param>
        /// <param name="pageSize">The pagesize</param>
        /// <returns></returns>
        ISearchLoginLogsExecResult ILogsManagement.SearchLoginLogs(DateTime? startDate, DateTime? endDate, string loginIP, long offset, long pageSize)
        {
            if (service == null || string.IsNullOrEmpty(token))
                return new SearchLoginLogsExecResult(Enums.ExecutionResults.Failed, "No active user.");

            try
            {
                long total;
                LoginLogEntry[] logs = service.SearchLoginLog(token, startDate, endDate, loginIP, offset, pageSize, out total);
                return new SearchLoginLogsExecResult(Diomede.SDK.Enums.ExecutionResults.Success, "Seach successful.", logs, total);
            }
            catch (Exception ex)
            {
                return new SearchLoginLogsExecResult(ex);
            }
        }

        #endregion



        #region ILogsManagement Members

        /// <summary>
        /// ILogsManagement.SearchInvoice implementation, see <see cref="ILogsManagement.SearchInvoiceLogs(DateTime?, DateTime?, InvoiceStatus)">IBillingManagement.SearchInvoice</see> for more information.
        /// </summary>
        /// <param name="startDate">Start Date</param>
        /// <param name="endDate">End Date</param>
        /// <param name="status">Invoice Status</param>
        /// <returns>Will return Invoice Execution Result, see <see cref="SearchInvoiceLogsExecResult"/>.</returns>
        ISearchInvoiceLogsExecResult ILogsManagement.SearchInvoiceLogs(DateTime? startDate, DateTime? endDate, InvoiceStatus status)
        {
            if (service == null || string.IsNullOrEmpty(token))
                return new SearchInvoiceLogsExecResult(Enums.ExecutionResults.Failed, "No active user.");
            try
            {
                InvoiceLogEntry[] invoices = service.SearchInvoiceLog(token, startDate, endDate, status);
                return new SearchInvoiceLogsExecResult(ExecutionResults.Success, "Invoice search successful.", invoices);
            }
            catch (Exception ex)
            {
                return new SearchInvoiceLogsExecResult(ex);
            }
        }

        #endregion
    }

    #endregion
}
